﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.OleDb;
using System.Configuration;
using System.Data;

/// <summary>
/// Summary description for Other
/// </summary>
public class Other
{
    public int other_asset_ID { get; set; }
    public int hardware_ID { get; set; }
    public String description { get; set; }
    public String type { get; set; }
    public String asset_Name { get; set; }
    public String brand_Name { get; set; }
    public String connString = "SELECT * FROM Other WHERE Other_Asset_ID = @Other_ID";


	public Other()
	{
		//
		// TODO: Add constructor logic here
		//
	}


    public Other getOtherAssetByID(int otherAssetID)
    {
        OleDbConnection myOleDbConnection = new OleDbConnection();
        myOleDbConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AssetDbConnection"].ConnectionString;

        OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
        myOleDbCommand.CommandText = connString;

        myOleDbConnection.Open();
        OleDbDataAdapter da = new OleDbDataAdapter(connString, myOleDbConnection);

        OleDbParameter computerIDParam = new OleDbParameter();
        computerIDParam.ParameterName = "@Other_ID";
        computerIDParam.OleDbType = OleDbType.Numeric;
        computerIDParam.Size = 255;
        computerIDParam.Direction = ParameterDirection.Input;
        computerIDParam.Value = otherAssetID;

        myOleDbCommand.Parameters.Add(computerIDParam);

        //myOleDbCommand.Connection.Open();
        OleDbDataReader dataReader = myOleDbCommand.ExecuteReader(CommandBehavior.CloseConnection);

        Other other = new Other();
        while (dataReader.Read())
        {
            other.other_asset_ID = Int32.Parse(dataReader["Other_Asset_ID"].ToString());
            other.hardware_ID = Int32.Parse(dataReader["Hardware_ID"].ToString());
            other.description = dataReader["Description"].ToString();
            other.asset_Name = dataReader["Asset_Name"].ToString();
            other.brand_Name = dataReader["Brand_Name"].ToString();
            other.type = dataReader["Type"].ToString();
        }

        myOleDbConnection.Close();
        myOleDbCommand.Connection.Close();

        return other;
    }






}